package cn.kgc.tafang.service;

import cn.kgc.tafang.dao.Init;
import cn.kgc.tafang.entity.Hero;
import cn.kgc.tafang.entity.Moster;
import cn.kgc.tafang.entity.Tower;

import java.util.*;


public class SkillOpera {
    static Map <String, Hero> heroMap= Init.heroMap;
    static List<Moster> mosters=Init.mosterList;

    public static void Skill() throws InterruptedException {
        List<Tower> towers=Init.towerList;
        Collection<Hero> heroCollection=heroMap.values();
        System.out.println("请选择想要使用的技能");
        System.out.println("1.攻击        （提高攻击力）");
        System.out.println("2.控制        （无视距离眩晕敌人两秒）");
        System.out.println("3.回复        （防御塔回复150点血）");
        Scanner sc=new Scanner(System.in);
        int choice1=sc.nextInt();
            switch (choice1){
                case 1:
                    for (Hero hero:heroCollection){
                        if ("攻击".equals(hero.getSkill1())) {
                            if (hero.getPowed() > 20) {
                                hero.setPowed(hero.getPowed() + 30);
                                hero.setAOE(hero.getAOE() + 5);
                                System.out.println("攻击力为:" + hero.getPowed() + "\t攻击距离为:" + hero.getDistance());
                                hero.setMongey(hero.getMongey() - 20);
                                System.out.println("技能使用成功!");
                            } else {
                                System.out.println("金币不足，无法使用！");
                            }
                        }else {
                            System.out.println("您没有装备该技能！");
                        }
                    }
                    break;
                case 2:
                    for (Hero hero:heroCollection){
                        for (Moster moster:mosters) {
                            for (Tower tower : towers) {
                                if ("控制".equals(hero.getSkill2())){
                                if (hero.getMongey()>40) {
                                    System.out.println("怪物被控制在原地两秒");
                                    System.out.println("可以疯狂输出啦！！(无视距离限制)");
                                    System.out.println(hero.getDistance());
                                    moster.setHP(moster.getHP() - hero.getPowed() - tower.getPower());
                                    Thread.sleep(2000);
                                    hero.setMongey(hero.getMongey()-40);
                                }else {
                                    System.out.println("金币不足，无法使用！");
                                }
                                }else {
                                    System.out.println("对不起您没有装备该技能!");
                                }
                            }
                        }
                    }
                    break;
                case 3:
                    for (Tower tower:towers){
                        for (Hero hero:heroCollection) {
                            if ("回复".equals(hero.getSkill3())) {
                                if (hero.getMongey() > 60) {
                                    tower.setHP(tower.getHP() + 150);
                                    hero.setMongey(hero.getMongey() - 60);
                                    System.out.println("技能使用成功！");
                                } else {
                                    System.out.println("金币不足，无法使用！");
                                }
                            }
                        }
                    }
                    break;
            }
    }


}
